<template>
	<view class="pages" :style="'height:'+h+'px;background:'+bg">
		
	</view>
</template>

<script>
import $util from '@/util/util';
	export default {
		data() {
			return {
				h:uni.getSystemInfoSync().windowHeight,
				bg:'#000'
			}
		},
		created() {
			this.san()
			this.h = uni.getSystemInfoSync().windowHeight
		},
		methods: {
			san(){
				let _ = this
				uni.scanCode({
					success: function (res) {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						//切割数组
						let arr = res.result.split("#daguo#");
						if(arr.length <= 1 ){
							_.san()
							$util.toast('这不是我们的码哦')
							return
						}
						$util.confirm('确认核销此款商品？',['确认','取消'],(iix)=>{
							if(iix == 1){
								$util.ajax({
									url:'Member/hexiao',
									datas:res.result
								},(r,e)=>{
									if(r.code == 1){
										$util.alert(r.msg,()=>{
											_.san()
										})
									}else{
										_.bg = 'red'
										setTimeout(()=>{
											_.bg = '#000'
										},2000)
										$util.alert(r.msg,()=>{
											_.san()
										})
									}
								})
							}else{
								_.san()
							}
						})
					}
				});
			}
		}
	}
</script>

<style scoped>
.pages{
	background: #000;
}
</style>
